package com.wuhongyu.eurekaclient2.controller;

import com.wuhongyu.eurekaclient2.feignclient.Client1FeignClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
@RequestMapping("/get_msg")
@Slf4j
public class TestRestController {

    @Autowired
    private RestTemplate restTemplate;



    @GetMapping
    public String getMsg(){
        String url = "http://CLIENT1/test";
        String result = restTemplate.getForObject(url, String.class);
        log.info("result = {}",result);
        return result;
    }

    @Autowired
    private Client1FeignClient client1FeignClient;

    @GetMapping("/feign")
    public String getMsg1(){
        String result = client1FeignClient.test();
        log.info("result = {}",result);
        return result;
    }

}